import subprocess
from threading import Thread

def ping(host):
    result = subprocess.run("ping -c 1 %s &>/dev/null" %host,shell=True)
    if result.returncode == 0:
        print("ip:%s 存活" %host)
    else:
        print("ip:%s 没有存活" %host)

if __name__ == "__main__":
    ip_all = ["192.168.0.%s" %i for i in range(1,255)]
    for ip in ip_all:
        t = Thread(target = ping,args = (ip,))
        t.start()
